#define STDOUT_FILENO 1

#include <stdlib.h>
#include <unistd.h>

int main(int argc __attribute__((unused)), char** argv __attribute__((unused)))
{
  const char *states = "|/-\\";
  int count = 0;
  
  while(write(STDOUT_FILENO, &states[count], 1) < 1);
  
  // loop through and print each state at a time
  while (1)
  {
    count = (count+1) % 4;
    while(write(STDOUT_FILENO, "\b", 1) < 1);
    while(write(STDOUT_FILENO, &states[count], 1) < 1);
    sleep(200);
  }
  return 0;
}
